package fr.adfm.entity;


import java.util.Collection;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity
public class Client extends Membre {

	private static final long serialVersionUID = 1L;
	
	private String nom;
    private String telephone;
    
	@OneToMany(mappedBy="client")
	private Collection<Commande> commandes = new LinkedHashSet<Commande>();
	
	@OneToOne(cascade=CascadeType.ALL)
	@JoinColumn(name = "Adresse_facturation_Id")
    private Adresse clientAdresseFacturation;

	@OneToMany(cascade=CascadeType.ALL)
	@JoinTable(name="CLientAdresseLivraison",
			joinColumns=@JoinColumn(name="Client_ID"),
			inverseJoinColumns=@JoinColumn(name="Adresse_ID"))
	private Collection<Adresse> livraisonAdresses = new LinkedHashSet<Adresse>();


	public Collection<Commande> getCommandes() {
		return commandes;
	}

	public void setCommandes(Collection<Commande> commandes) {
		this.commandes = commandes;
	}


	public Client() {
    	this.setProfil(Profil.Client);
    }

	public Client(String motDePasse, String email, String nom, String telephone) {
		this.setProfil(Profil.Client);
		
		this.setMotDePasse(motDePasse);
		this.setEmail(email);
		
		this.nom = nom;
		this.telephone = telephone;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}


	public Adresse getClientAdresseFacturation() {
		return clientAdresseFacturation;
	}


	public void setClientAdresseFacturation(Adresse clientAdresseFacturation) {
		this.clientAdresseFacturation = clientAdresseFacturation;
	}


	public Collection<Adresse> getLivraisonAdresses() {
		return livraisonAdresses;
	}


	public void setLivraisonAdresses(Collection<Adresse> livraisonAdresses) {
		this.livraisonAdresses = livraisonAdresses;
	}


	
}
